Method and apparatus for generating neural network

ABSTRACT

Embodiments of the present disclosure relate to a method and apparatus for generating a neural network. The method includes: acquiring a target neural network, the target neural network corresponding to a preset association relationship, and being configured to use two entity vectors corresponding to two entities in a target knowledge graph as an input, to determine whether an association relationship between the two entities corresponding to the inputted two entity vectors is the preset association relationship, the target neural network comprising a relational tensor predetermined for the preset association relationship; converting the relational tensor in the target neural network into a product of a target number of relationship matrices, and generating a candidate neural network comprising the target number of converted relationship matrices; and generating a resulting neural network using the candidate neural network.

CROSS-REFERENCE TO RELATED APPLICATIONS

This application claims priority to Chinese Application No.201910184509.9, filed on Mar. 12, 2019 and entitled “Method andApparatus for Generating Neural Network,” the entire disclosure of whichis hereby incorporated by reference.

TECHNICAL FIELD

Embodiments of the present disclosure relate to the field of computertechnology, and specifically to a method and apparatus for generating aneural network.

BACKGROUND

The knowledge graph is a network composed of a large number ofstructured triples. Nodes in the network represent entities, and an edgebetween nodes represents an association relationship between theentities.

At present, the knowledge graph may be applied to various fields, suchas information search, and information recommendation. With theknowledge graph, other entities associated with an entity correspondingto a piece of information can be obtained, and then other informationassociated with the information can be obtained.

SUMMARY

Embodiments of the present disclosure present a method and apparatus forgenerating a neural network, and a method and apparatus for updating aknowledge graph.

In a first aspect, an embodiment of the present disclosure provides amethod for generating a neural network, including: acquiring a targetneural network, the target neural network corresponding to a presetassociation relationship, and being configured to use two entity vectorscorresponding to two entities in a target knowledge graph as an input,to determine whether an association relationship between the twoentities corresponding to the inputted two entity vectors is the presetassociation relationship, the target neural network including arelational tensor predetermined for the preset association relationship;converting the relational tensor in the target neural network into aproduct of a target number of relationship matrices, and generating acandidate neural network including the target number of convertedrelationship matrices; and generating a resulting neural network usingthe candidate neural network.

In some embodiments, the generating a resulting neural network using thecandidate neural network includes: acquiring a training sample set forthe preset association relationship, where the training sample setincludes a positive training sample and a negative training sample, atraining sample includes two sample entity vectors, the sample entityvector is used for characterizing a sample entity, an associationrelationship between two entities corresponding to the positive trainingsample is the preset association relationship, and an associationrelationship between two entities corresponding to the negative trainingsample is not the preset association relationship; and selecting atraining sample from the training sample set, and executing followingtraining: training the candidate neural network using the selectedtraining sample; determining whether the training the candidate neuralnetwork is completed; and determining, in response to determining thetraining the candidate neural network being completed, the trainedcandidate neural network as the resulting neural network.

In some embodiments, the generating a resulting neural network using thecandidate neural network further includes: reselecting, in response todetermining the training the candidate neural network being uncompleted,a training sample from unselected training samples included in thetraining sample set, adjusting a parameter of the candidate neuralnetwork, and continuing to execute the training using a most recentlyselected training sample and a most recently adjusted candidate neuralnetwork.

In some embodiments, the acquiring a training sample set for the presetassociation relationship includes: acquiring a positive training sampleset for the preset association relationship; determining, for a positivetraining sample in the positive training sample set, a to-be-retainedsample entity vector and a to-be-replaced sample entity vector from thepositive training sample; acquiring a sample entity vector forreplacement for the to-be-replaced sample entity vector, where a sampleentity corresponding to the sample entity vector for replacement isdifferent from a sample entity corresponding to the to-be-replacedsample entity vector; and using the sample entity vector for replacementand the to-be-retained sample entity vector to form a negative trainingsample corresponding to the positive training sample; and using thepositive training sample set and the formed negative training sample toform the training sample set.

In some embodiments, the method further includes: storing the resultingneural network.

In a second aspect, an embodiment of the present disclosure provides amethod for updating a knowledge graph, including: acquiring twoto-be-associated entity vectors and a pre-generated resulting neuralnetwork, the to-be-associated entity vectors being used forcharacterizing to-be-associated entities in a target knowledge graph,the resulting neural network being generated using the method accordingto any one embodiment of the method in the first aspect; inputting theacquired two to-be-associated entity vectors into the resulting neuralnetwork, to generate an association result for characterizing whether anassociation relationship between the two to-be-associated entities is apreset association relationship corresponding to the resulting neuralnetwork; and updating the target knowledge graph, in response todetermining the association result indicating the associationrelationship between the two to-be-associated entities being the presetassociation relationship corresponding to the resulting neural network,using association information preset for the preset associationrelationship and to be added to the knowledge graph.

In some embodiments, the method further includes: displaying the updatedtarget knowledge graph.

In a third aspect, an embodiment of the present disclosure provides anapparatus for generating a neural network, including: a first acquiringunit configured to acquire a target neural network, the target neuralnetwork corresponding to a preset association relationship, and beingconfigured to use two entity vectors corresponding to two entities in atarget knowledge graph as an input, to determine whether an associationrelationship between the two entities corresponding to the inputted twoentity vectors is the preset association relationship, the target neuralnetwork including a relational tensor predetermined for the presetassociation relationship; a tensor converting unit configured to convertthe relational tensor in the target neural network into a product of atarget number of relationship matrices, and generate a candidate neuralnetwork including the target number of converted relationship matrices;and a network generating unit configured to generate a resulting neuralnetwork using the candidate neural network.

In some embodiments, the network generating unit includes: a sampleacquiring module configured to acquire a training sample set for thepreset association relationship, where the training sample set includesa positive training sample and a negative training sample, a trainingsample includes two sample entity vectors, the sample entity vector isused for characterizing a sample entity, an association relationshipbetween two entities corresponding to the positive training sample isthe preset association relationship, and an association relationshipbetween two entities corresponding to the negative training sample isnot the preset association relationship; and a first training moduleconfigured to select a training sample from the training sample set, andexecute following training: training the candidate neural network usingthe selected training sample; determining whether the training thecandidate neural network is completed; and determining, in response todetermining the training the candidate neural network being completed,the trained candidate neural network as the resulting neural network.

In some embodiments, the network generating unit further includes: asecond training module configured to reselect, in response todetermining the training the candidate neural network being uncompleted,a training sample from unselected training samples included in thetraining sample set, adjust a parameter of the candidate neural network,and continue to execute the training using a most recently selectedtraining sample and a most recently adjusted candidate neural network.

In some embodiments, the sample acquiring module is further configuredto: acquire a positive training sample set for the preset associationrelationship; determine, for a positive training sample in the positivetraining sample set, a to-be-retained sample entity vector and ato-be-replaced sample entity vector from the positive training sample;acquire a sample entity vector for replacement for the to-be-replacedsample entity vector, where a sample entity corresponding to the sampleentity vector for replacement is different from a sample entitycorresponding to the to-be-replaced sample entity vector; and use thesample entity vector for replacement and the to-be-retained sampleentity vector to form a negative training sample corresponding to thepositive training sample; and use the positive training sample set andthe formed negative training sample to form the training sample set.

In some embodiments, the apparatus further includes: a network storingmodule configured to store the resulting neural network.

In a fourth aspect, an embodiment of the present disclosure provides anapparatus for updating a knowledge graph, including: a second acquiringunit configured to acquire two to-be-associated entity vectors and apre-generated resulting neural network, the to-be-associated entityvector being used for characterizing to-be-associated entities in atarget knowledge graph, the resulting neural network being generatedusing the method according to any one embodiment of the method in thefirst aspect; a result generating unit configured to input the acquiredtwo to-be-associated entity vectors into the resulting neural network,to generate an association result for characterizing whether anassociation relationship between the two to-be-associated entities is apreset association relationship corresponding to the resulting neuralnetwork; and a graph updating unit configured to update the targetknowledge graph, in response to determining the association resultindicating the association relationship between the two to-be-associatedentities being the preset association relationship corresponding to theresulting neural network, using association information preset for thepreset association relationship and to be added to the knowledge graph.

In some embodiments, the apparatus further includes: a graph displayingunit configured to display the updated target knowledge graph.

In a fifth aspect, an embodiment of the present disclosure provides anelectronic device, including: one or more processors; and a storageapparatus, storing one or more programs thereon, where the one or moreprograms, when executed by the one or more processors, cause the one ormore processors to implement the method according to any one embodimentof the method in the first aspect and the second aspect.

In a sixth aspect, an embodiment of the present disclosure provides acomputer readable medium, storing a computer program thereon, where theprogram, when executed by a processor, implements the method accordingto any one embodiment of the method in the first aspect and the secondaspect.

The method and apparatus for generating a neural network provided bysome embodiments of the present disclosure acquire a target neuralnetwork, the target neural network corresponding to a preset associationrelationship, and being configured to use two entity vectorscorresponding to two entities in a target knowledge graph as an input,to determine whether an association relationship between the twoentities corresponding to the inputted two entity vectors is the presetassociation relationship, the target neural network including arelational tensor predetermined for the preset association relationship,then convert the relational tensor in the target neural network into aproduct of a target number of relationship matrices, and generate acandidate neural network including the target number of convertedrelationship matrices, and finally generate a resulting neural networkusing the candidate neural network, thereby reducing the number ofparameters of the neural network by converting the relational tensor inthe neural network into the product of the target number of relationshipmatrices, further reducing the complexity of the neural network, andfacilitating reducing the CPU consumption and improving the informationprocessing efficiency when performing information processing using theneural network.

BRIEF DESCRIPTION OF THE DRAWINGS

After reading detailed descriptions of non-limiting embodiments withreference to the following accompanying drawings, other features,objectives and advantages of the present disclosure will become moreapparent.

FIG. 1 is a diagram of an example system architecture in which anembodiment of the present disclosure may be implemented;

FIG. 2 is a flowchart of a method for generating a neural networkaccording to an embodiment of the present disclosure;

FIG. 3 is a schematic diagram of an application scenario of the methodfor generating a neural network according to an embodiment of thepresent disclosure;

FIG. 4 is a flowchart of a method for updating a knowledge graphaccording to an embodiment of the present disclosure;

FIG. 5 is a schematic structural diagram of an apparatus for generatinga neural network according to an embodiment of the present disclosure;

FIG. 6 is a schematic structural diagram of an apparatus for updating aknowledge graph according to an embodiment of the present disclosure;and

FIG. 7 is a schematic structural diagram of a computer system adapted toimplement an electronic device of embodiments of the present disclosure.

DETAILED DESCRIPTION OF EMBODIMENTS

Embodiments of present disclosure will be described below in detail withreference to the accompanying drawings. It should be appreciated thatthe specific embodiments described herein are merely used for explainingthe relevant disclosure, rather than limiting the disclosure. Inaddition, it should be noted that, for the ease of description, only theparts related to the relevant disclosure are shown in the accompanyingdrawings.

It should also be noted that some embodiments in the present disclosureand some features in the disclosure may be combined with each other on anon-conflict basis. Features of the present disclosure will be describedbelow in detail with reference to the accompanying drawings and incombination with embodiments.

FIG. 1 shows an example system architecture 100 in which a method forgenerating a neural network, an apparatus for generating a neuralnetwork, a method for updating a knowledge graph, or an apparatus forupdating a knowledge graph according to embodiments of the presentdisclosure may be applied.

As shown in FIG. 1 , the system architecture 100 may include terminaldevices 101, 102, and 103, a network 104, and a server 105. The network104 serves as a medium providing a communication link between theterminal devices 101, 102, and 103, and the server 105. The network 104may include various types of connections, such as wired or wirelesscommunication links, or optical cables.

A user may interact with the server 105 using the terminal devices 101,102, and 103 via the network 104, for example, to receive or transmit amessage. The terminal devices 101, 102, and 103 may be provided withvarious communication client applications, such as a web browserapplication, a shopping application, a search application, an instantmessaging tool, an mailbox client, or social platform software.

The terminal devices 101, 102, and 103 may be hardware or software. Whenthe terminal devices 101, 102 and 103 are hardware, the terminal devicesmay be various electronic devices, including but not limited to a smartphone, a tablet PC, an e-book reader, an MP3 (Moving Picture ExpertsGroup Audio Layer III) player, an MP4 (Moving Picture Experts GroupAudio Layer IV) player, a laptop portable computer, or a desktopcomputer. When the terminal devices 101, 102, and 103 are software, theterminal devices may be installed in the above-listed electronicdevices, may be implemented as a plurality of software programs orsoftware modules (e.g., software programs or software modules configuredto provide distributed services), or may be implemented as a singlesoftware program or software module. This is not specifically limitedhere.

The server 105 may be a server that provides various services, such as anetwork processing server for processing a target neural networktransmitted by the terminal devices 101, 102 and 103. The networkprocessing server can process, e.g., analyze, received data, such as thetarget neural network, and obtain a processing result (e.g., a resultingneural network).

It should be noted that the method for generating a neural networkprovided in some embodiments of the present disclosure may be executedby the terminal devices 101, 102, and 103, or be executed by the server105. Accordingly, the apparatus for generating a neural network may beprovided in the terminal devices 101, 102, and 103, or be provided inthe server 105. In addition, the method for updating a knowledge graphprovided in some embodiments of the present disclosure may be executedby the terminal devices 101, 102, and 103, or be executed by the server105. Accordingly, the apparatus for updating a knowledge graph may beprovided in the terminal devices 101, 102, and 103, or be provided inthe server 105.

It should be noted that the server may be hardware or software. When theserver is hardware, the server may be implemented as a distributedserver cluster composed of a plurality of servers, or be implemented asa single server. When the server is software, the server may beimplemented as a plurality of software programs or software modules(e.g., a plurality of software programs or software modules forproviding distributed services), or may be implemented as a singlesoftware program or software module. This is not specifically limitedhere.

It should be understood that the numbers of terminal devices, networks,and servers in FIG. 1 are merely illustrative. Any number of terminaldevices, networks, and servers may be provided based on actualrequirements. In the case where it is not necessary to remotely acquiredata for generating the resulting neural network or updating a targetknowledge graph, the system architecture may not include the network,but merely includes the terminal device or the server.

Further referring to FIG. 2 , a process 200 of a method for generating aneural network according to an embodiment of the present disclosure isshown. The method for generating a neural network includes the followingsteps.

Step 201: acquiring a target neural network.

In the present embodiment, an executing body (e.g., the server shown inFIG. 1 ) of the method for generating a neural network can acquire atarget neural network remotely or locally through a wired or wirelessconnection. The target neural network is a to-be-adjusted neuralnetwork. Specifically, the target neural network may be an untrainedneural network, or a trained neural network. The target neural networkcorresponds to a preset association relationship, and is configured touse two entity vectors corresponding to two entities in a targetknowledge graph as an input, to determine whether an associationrelationship between the two entities corresponding to the inputted twoentity vectors is the preset association relationship.

The target knowledge graph is a knowledge graph with ato-be-complemented association relationship between entities therein.The target knowledge graph may be stored in the executing body, or inother electronic devices in communicative connection with the executingbody. Generally, an entity in the knowledge graph may be used forcharacterizing a thing or concept (e.g., characterizing a person, aplace, time, or information). A form of the entity may include at leastone of the following items: a numeral, a word, or a symbol. Theassociation relationship in the knowledge graph may be characterized bya connection line between entities, and a specific content of anassociation relationship corresponding to two associated entities may becharacterized by association information predetermined for theassociation relationship. The association information may include atleast one of the following items: a numeral, a word, or a symbol.

As an example, the target knowledge graph includes an entity “Beijing”and an entity “China,” which may include a connection line forcharacterizing that both have an association relationship, as well asassociation information for characterizing a specific content of theassociation relationship between the two, e.g., a word “capital.”

An entity in the target knowledge graph may correspond to an entityvector. The entity vector may be used for characterizing acharacteristic of the entity. In practice, the entity vector may beobtained by various approaches, for example, may be obtained byinitialization, or be obtained using a pre-trained machine learningmodel.

The preset association relationship may be various associationrelationships predetermined by those skilled in the art, such as aparent-child relationship, or an inclusion relationship. The targetneural network includes a relational tensor predetermined for the presetassociation relationship. The relational tensor may be used forcharacterizing a characteristic of the preset association relationship.

In practice, a tensor is a multi-dimensional data storing unit, and thedata dimension is referred to as an order of the tensor. The tensor maybe regarded as expansion of a vector and a matrix in a multi-dimensionalspace, the vector may be regarded as a one-dimensional tensor, and thematrix may be regarded as a two-dimensional tensor. Generally, duringresearch on the tensor, the tensor may be regarded as a plurality oftwo-dimensional slices. Each of the slices may be regarded as a matrix.

Specifically, the executing body or other electronic devices maydetermine a relational tensor corresponding to the preset associationrelationship using various methods. For example, the relational tensorcorresponding to the preset association relationship may be determinedusing various conventional parameter initialization methods (e.g.,random initialization, or Glove algorithm). Alternatively, therelational tensor corresponding to the preset association relationshipmay be determined using a pre-trained model for characterizing acorresponding relationship between the association relationship and therelational tensor.

In the present embodiment, the relational tensor is used for performingoperation on entity vectors of the two entities in the target knowledgegraph, thereby determining whether the association relationship betweenthe two entities in the target knowledge graph is the preset associationrelationship corresponding to the relational tensor. It will beappreciated that, compared with the matrix or the vector, the relationaltensor has a large dimension, such that more characteristic data forcharacterizing characteristics of the preset association relationshipsmay be stored using the relational tensor. However, in practice, themore are the parameters included in the neural network, the more complexwill the neural network be, which will not contribute to storage orcomputing of the neural network.

Step 202: converting the relational tensor in the target neural networkinto a product of a target number of relationship matrices, andgenerating a candidate neural network including the target number ofconverted relationship matrices.

In the present embodiment, based on the target neural network obtainedin step 201, the executing body can convert the relational tensor in thetarget neural network into a product of a target number of relationshipmatrices, and generate a candidate neural network including the targetnumber of converted relationship matrices.

The relationship matrices are obtained by converting the relationaltensor using a preset conversion method. The target number is determinedbased on the preset conversion method. It will be appreciated that, inpractice, when a high-dimensional matrix is converted into a product oflow-dimensional vectors, the number of elements included in theconverted vectors is generally less than the number of elements includedin the matrix. For example, a matrix A: [1 1 1;1 1 1;1 1 1] may beconverted into a product of a vector b: [1 1 1]^(T) and a vector c: [1 11]. The letter “T” is used for characterizing transposition of thevector. Thus, the matrix A includes 9 elements, and a sum of elementsincluded in the converted two vectors is 6, i.e., the number of elementsin the matrix A is greater than the number of elements included in theconverted vector b and vector c. Furthermore, similarly, when ahigh-dimensional relational tensor is converted into a product of atarget number of low-dimensional relationship matrices, the number ofparameters corresponding to the preset association relationship can bereduced, thereby reducing the complexity of the neural network.

Specifically, the executing body can convert the relational tensor byvarious approaches, to obtain the target number of relationshipmatrices. For example, the executing body can first aggregate matricescorresponding to slices of the relational tensor, to construct therelational tensor into a slice matrix. Then, the slice matrix isdecomposed into a product of a target number of relationship matrices.Here, the slice matrix may be decomposed by various approaches, e.g.,triangular factorization, QR factorization, or singular valuedecomposition. It should be noted that when different decompositionmethods are employed, the number (i.e., the target number) of finallyobtained relationship matrices may be different. For example, tworelationship matrices may be obtained from decomposition by triangularfactorization; while three relationship matrices may be obtained fromdecomposition by singular value decomposition.

In addition, the executing body can further convert the relationaltensor by other approaches. As an example, the relational tensor Wincludes three slices, respectively being W₁, W₂, and W₃. The executingbody may first construct the relational tensor W into a slice matrixW′=[W₁, W₂, W₃], then convert each matrix element (namely Wi, wherei=1,2,3) in the slice matrix into a product of two vectors, i.e.,converting W₁ into U₁ ^(T)*V₁; converting W₂ into U₂ ^(T)*V₂; andconverting W₃ into U₃ ^(T)*V₃; and then may infer:W=W′=[U ₁ ^(T) *V ₁ ,U ₂ ^(T) *V ₂ ,U ₃ ^(T) *V ₃]=[U ₁ ,U ₂ ,U₃]^(T)*[V ₁ ,V ₂ ,V ₃]

A matrix [U₁, U₂, U₃]^(T) and a matrix [V₁, V₂, V₃] are two convertedrelationship matrices.

For the example described above, assuming that W_(i) is a matrix in 3×3dimensions, then W_(i) includes 9 parameters, and then the relationaltensor W includes 27 (27=9×3) parameters. Converted U_(i) ^(T)corresponding to W_(i) is a 3-dimensional column vector, including 3parameters; and V_(i) is a three-dimensional row vector, including 3parameters. Therefore, the converted relationship matrix [U₁, U₂,U₃]^(T) includes 9 parameters; and the converted relationship matrix[V₁, V₂, V₃] also includes 9 parameters, i.e., after converting therelational tensor into relationship matrices, the number of parametersis 18 (18=9+9), which is less than the number (27) of parametersincluded in the relational tensor, thereby achieving the purpose ofreducing the number of parameters in the neural network.

In the present embodiment, the candidate neural network is the targetneural network obtained by replacing the relational tensor with theproduct of the target number of converted relationship matrices.

Step 203: generating a resulting neural network using the candidateneural network.

In the present embodiment, the executing body can generate the resultingneural network based on the candidate neural network obtained in step202. The resulting neural network is an adjusted neural network.

Specifically, the executing body can directly determine the candidateneural network as the resulting neural network; or alternatively, cancontinue to adjust the candidate neural network, and determine theadjusted candidate neural network as the resulting neural network.

In some alternative implementations of the present embodiment, theexecuting body can generate the resulting neural network using thecandidate neural network through the following steps.

Step 2031: acquiring a training sample set for the preset associationrelationship.

The training sample set includes a positive training sample and anegative training sample. A training sample includes two sample entityvectors. The sample entity vector is used for characterizing a sampleentity. An association relationship between two entities correspondingto the positive training sample is the preset association relationship.An association relationship between two entities corresponding to thenegative training sample is not the preset association relationship. Forexample, the preset association relationship is an inclusionrelationship. For the inclusion relationship, the positive trainingsample may be two sample entity vectors corresponding to a sample entity“China” and a sample entity “Beijing;” and the negative training samplemay be two sample entity vectors corresponding to a sample entity“Tianjin” and a sample entity “Beijing.”

Specifically, the executing body can acquire the training sample setusing various methods.

In some alternative implementations of the present embodiment, theexecuting body can acquire the training sample set through the followingsteps.

First, the executing body can acquire the positive training sample setfor the preset association relationship.

Here, the positive training sample can be acquired using variousmethods, for example, two entities corresponding to the presetassociation relationship may be searched in a predetermined sampleknowledge graph as sample entities. Then, entity vectors of the searchedtwo entities are determined as the sample entity vectors. Finally, thedetermined two sample entity vectors are used to form the positivetraining sample.

Then, for a positive training sample in the positive training sampleset, the following steps are executed: determining a to-be-retainedsample entity vector and a to-be-replaced sample entity vector from thepositive training sample; acquiring a sample entity vector forreplacement for the to-be-replaced sample entity vector, where a sampleentity corresponding to the sample entity vector for replacement isdifferent from a sample entity corresponding to the to-be-replacedsample entity vector; and using the sample entity vector for replacementand the to-be-retained sample entity vector to form a negative trainingsample corresponding to the positive training sample.

Finally, the positive training sample set and the formed negativetraining sample are used to form the training sample set.

In the present implementation, the negative training sample is obtainedby replacing the to-be-replaced sample entity vector in the positivetraining sample, thereby simplifying the acquisition of a trainingsample set, and further contributing to improving the efficiency ofgenerating the result generating network.

Step 2032: selecting a training sample from the training sample set, andexecuting following training: training the candidate neural networkusing the selected training sample; determining whether the training thecandidate neural network is completed; and determining, in response todetermining the training the candidate neural network being completed,the trained candidate neural network as the resulting neural network.

Specifically, the executing body can train the candidate neural networkusing the selected training sample by using the machine learning method.

Here, whether the training the candidate neural network is completed maybe determined based on a predetermined completion condition. When thecompletion condition is satisfied, the completion of training thecandidate neural network may be determined. The completion condition mayinclude, but is not limited to, at least one of the following items: atraining duration exceeding a preset time length; a number of iterationsof training exceeding a preset number of iterations; or a loss valueobtained through computation using a loss function being less than apreset loss threshold.

In the present implementation, the resulting neural network is obtainedby training the candidate neural network, thereby improving the accuracyof the obtained resulting neural network, and contributing to improvingthe accuracy degree of prediction using the resulting neural network.

In some alternative implementations of the present embodiment, theexecuting body can further reselect, in response to determining thetraining the candidate neural network being uncompleted, a trainingsample from unselected training samples included in the training sampleset, adjust parameters of the candidate neural network, and continue toexecute the training using a most recently selected training sample anda most recently adjusted candidate neural network.

Specifically, the executing body can adjust the parameters of thecandidate neural network, in response to determining the training thecandidate neural network being uncompleted, based on differencesobtained through computation. Here, the parameters of the candidateneural network can be adjusted by various implementation approachesbased on the differences obtained through computation. For example, theparameters of the candidate neural network can be adjusted by a backpropagation (BP) algorithm or a stochastic gradient descent (SGD)algorithm.

The present implementation can achieve repeated training of thecandidate neural network, thereby further improving the accuracy of theresulting neural network.

In some alternative implementations of the present embodiment, theexecuting body can store the resulting neural network. Here, as theresulting neural network corresponds to the target neural network, andthe number of included parameters is reduced, the resulting neuralnetwork can be stored to reduce the storage space occupied by the neuralnetwork, and save the storage resource.

Further referring to FIG. 3 , FIG. 3 is a schematic diagram of anapplication scenario of the method for generating a neural networkaccording to an embodiment of the present disclosure. In the applicationscenario of FIG. 3 , the server 301 first acquires a target neuralnetwork 302. The target neural network 302 corresponds to a presetassociation relationship (e.g., a parent-child relationship), and isconfigured to use two entity vectors corresponding to two entities in atarget knowledge graph as an input, to determine whether an associationrelationship between the two entities corresponding to the inputted twoentity vectors is the preset association relationship. The target neuralnetwork 302 includes a relational tensor 303 predetermined for thepreset association relationship. Then, the server 301 can convert therelational tensor 303 in the target neural network 302 into a product ofa relationship matrix 304 and a relationship matrix 305, and generate acandidate neural network 306 including the converted relationship matrix304 and the converted relationship matrix 305. Finally, the server 301can generate a resulting neural network 307 using the candidate neuralnetwork 306.

The method provided in some embodiments of the present disclosureacquires a target neural network, the target neural networkcorresponding to a preset association relationship, and being configuredto use two entity vectors corresponding to two entities in a targetknowledge graph as an input, to determine whether an associationrelationship between the two entities corresponding to the inputted twoentity vectors is the preset association relationship, the target neuralnetwork including a relational tensor predetermined for the presetassociation relationship, then converts the relational tensor in thetarget neural network into a product of a target number of relationshipmatrices, and generates a candidate neural network including the targetnumber of converted relationship matrices, and finally generates aresulting neural network using the candidate neural network, therebyreducing the number of parameters of the neural network by convertingthe relational tensor in the neural network into the product of thetarget number of relationship matrices, further reducing the complexityof the neural network, and facilitating reducing the CPU consumption andimproving the information processing efficiency when performinginformation processing using the neural network.

Further referring to FIG. 4 , a process 400 of an embodiment of a methodfor updating a knowledge graph is shown. The process 400 of the methodfor updating a knowledge graph includes the following steps.

Step 401: acquiring two to-be-associated entity vectors and apre-generated resulting neural network.

In the present embodiment, an executing body (e.g., the terminal deviceshown in FIG. 1 ) of the method for updating a knowledge graph canacquire two to-be-associated entity vectors and a pre-generatedresulting neural network remotely or locally through a wired or wirelessconnection. The to-be-associated entity vectors are used forcharacterizing to-be-associated entities in a target knowledge graph.Specifically, the executing body may first extract two to-be-associatedentities from the target knowledge graph, and then determineto-be-associated entity vectors of the extracted two to-be-associatedentities. The method of determining an entity vector described in FIG. 2may be referred to for the method of specifically determining theto-be-associated entity vectors corresponding to the to-be-associatedentities.

In the present embodiment, the resulting neural network is generated inaccordance with the method according to the corresponding embodiment ofthe above FIG. 2 . Specifically, the steps according to thecorresponding embodiment of FIG. 2 may be referred to.

Step 402: inputting the acquired two to-be-associated entity vectorsinto the resulting neural network, to generate an association result forcharacterizing whether an association relationship between the twoto-be-associated entities is a preset association relationshipcorresponding to the resulting neural network.

In the present embodiment, based on the two to-be-associated entityvectors and the resulting neural network obtained in step 401, theexecuting body can input the acquired two to-be-associated entityvectors into the resulting neural network, to generate the associationresult for characterizing whether the association relationship betweenthe two to-be-associated entities is the preset association relationshipcorresponding to the resulting neural network. The association resultmay include at least one of the following items: a word, a numeral, or asymbol. For example, the association result may include a word “yes” ora word “no,” where the word “yes” may be used for characterizing thatthe association relationship between the two to-be-associated entitiesis the preset association relationship corresponding to the resultingneural network; and the word “no” may be used for characterizing thatthe association relationship between the two to-be-associated entitiesis not the preset association relationship corresponding to theresulting neural network.

Step 403: updating the target knowledge graph, in response todetermining the association result indicating the associationrelationship between the two to-be-associated entities being the presetassociation relationship corresponding to the resulting neural network,using association information preset for the preset associationrelationship and to be added to the knowledge graph.

In the present embodiment, after generating the association result, theexecuting body can update the target knowledge graph, in response todetermining the association result indicating the associationrelationship between the two to-be-associated entities being the presetassociation relationship corresponding to the resulting neural network,using the association information preset for the preset associationrelationship and to be added to the knowledge graph.

Specifically, the executing body can add the association informationbetween the to-be-associated entities, to characterize a content of theassociation relationship between the two to-be-associated entities.

In particular, when updating the target knowledge graph, if originalassociation information for characterizing the content of theassociation relationship between the two to-be-associated entities isincluded between two to-be-associated entities in the target knowledgegraph, the executing body can replace the original associationinformation with the association information corresponding to the presetassociation relationship, to achieve the updating the target knowledgegraph.

In some alternative implementations of the present embodiment, afterupdating the target knowledge graph, the executing body can furtherdisplay the updated target knowledge graph, thus intuitively displayingthe updated target knowledge graph.

The method provided in some embodiments of the present disclosure canupdate the target knowledge graph using the resulting neural networkgenerated using the method according to the corresponding embodiment ofFIG. 2 . The resulting neural network includes fewer parameters,compared with a tensor neural network for updating the knowledge graphin the prior art. Thus, the resulting neural network can be used toreduce the computing complexity, thereby reducing the CPU consumption,and improving the efficiency of updating the knowledge graph.

Further referring to FIG. 5 , as an implementation of the method shownin the above FIG. 2 , an embodiment of the present disclosure providesan apparatus for generating a neural network. An embodiment of theapparatus may correspond to the embodiment of the method shown in FIG. 2. The apparatus may be specifically applied to various electronicdevices.

As shown in FIG. 5 , the apparatus 500 for generating a neural networkof the present embodiment includes: a first acquiring unit 501, a tensorconverting unit 502, and a network generating unit 503. The firstacquiring unit 501 is configured to acquire a target neural network, thetarget neural network corresponding to a preset associationrelationship, and being configured to use two entity vectorscorresponding to two entities in a target knowledge graph as an input,to determine whether an association relationship between the twoentities corresponding to the inputted two entity vectors is the presetassociation relationship, the target neural network including arelational tensor predetermined for the preset association relationship;the tensor converting unit 502 is configured to convert the relationaltensor in the target neural network into a product of a target number ofrelationship matrices, and generate a candidate neural network includingthe target number of converted relationship matrices; and the networkgenerating unit 503 is configured to generate a resulting neural networkusing the candidate neural network.

In the present embodiment, the first acquiring unit 501 of the apparatusfor generating a neural network can acquire the target neural networkremotely or locally through a wired or wireless connection. The targetneural network is a to-be-adjusted neural network. Specifically, thetarget neural network may be an untrained neural network, or a trainedneural network. The target neural network corresponds to a presetassociation relationship, and is configured to use two entity vectorscorresponding to two entities in a target knowledge graph as an input,to determine whether an association relationship between the twoentities corresponding to the inputted two entity vectors is the presetassociation relationship.

The preset association relationship may be various associationrelationships predetermined by those skilled in the art, such as aparent-child relationship, or an inclusion relationship. The targetneural network includes a relational tensor predetermined for the presetassociation relationship. The relational tensor may be used forcharacterizing the preset association relationship.

In the present embodiment, based on the target neural network obtainedby the first acquiring unit 501, the tensor converting unit 502 canconvert the relational tensor in the target neural network into aproduct of a target number of relationship matrices, and generate acandidate neural network including the target number of convertedrelationship matrices. The relationship matrix is a matrix obtained byconverting the relational tensor using a preset conversion method. Thetarget number is a number determined based on the preset conversionmethod.

In the present embodiment, the candidate neural network is the targetneural network obtained by replacing the relational tensor with theproduct of the target number of converted relationship matrices.

In the present embodiment, the network generating unit 503 can generatethe resulting neural network based on the candidate neural networkobtained by the tensor converting unit 502. The resulting neural networkis an adjusted neural network.

In some alternative implementations of the present embodiment, thenetwork generating unit 503 may include: a sample acquiring module (notshown in the figure) configured to acquire a training sample set for thepreset association relationship, where the training sample set includesa positive training sample and a negative training sample, a trainingsample includes two sample entity vectors, the sample entity vector isused for characterizing a sample entity, an association relationshipbetween two entities corresponding to the positive training sample isthe preset association relationship, and an association relationshipbetween two entities corresponding to the negative training sample isnot the preset association relationship; and a first training module(not shown in the figure) configured to select a training sample fromthe training sample set, and execute following training: training thecandidate neural network using the selected training sample; determiningwhether the training the candidate neural network is completed; anddetermining, in response to determining the training the candidateneural network being completed, the trained candidate neural network asthe resulting neural network.

In some alternative implementations of the present embodiment, thenetwork generating unit 503 may further include: a second trainingmodule (not shown in the figure) configured to reselect, in response todetermining the training the candidate neural network being uncompleted,a training sample from unselected training samples included in thetraining sample set, adjust a parameter of the candidate neural network,and continue to execute the training using a most recently selectedtraining sample and a most recently adjusted candidate neural network.

In some alternative implementations of the present embodiment, thesample acquiring module may be further configured to: acquire a positivetraining sample set for the preset association relationship; determine,for a positive training sample in the positive training sample set, ato-be-retained sample entity vector and a to-be-replaced sample entityvector from the positive training sample; acquire a sample entity vectorfor replacement for the to-be-replaced sample entity vector, where asample entity corresponding to the sample entity vector for replacementis different from a sample entity corresponding to the to-be-replacedsample entity vector; and use the sample entity vector for replacementand the to-be-retained sample entity vector to form a negative trainingsample corresponding to the positive training sample; and use thepositive training sample set and the formed negative training sample toform the training sample set.

In some alternative implementations of the present embodiment, theapparatus 500 may further include: a network storing unit (not shown inthe figure) configured to store the resulting neural network.

It should be understood that the units disclosed in the apparatus 500may correspond to the steps in the method described with reference toFIG. 2 . Therefore, the operations, features, and resulting benefitingeffects described above for the method also apply to the apparatus 500and the units included therein. The description will not be repeatedhere.

The apparatus 500 provided in the above embodiments of the presentdisclosure acquires a target neural network, the target neural networkcorresponding to a preset association relationship, and being configuredto use two entity vectors corresponding to two entities in a targetknowledge graph as an input, to determine whether an associationrelationship between the two entities corresponding to the inputted twoentity vectors is the preset association relationship, the target neuralnetwork including a relational tensor predetermined for the presetassociation relationship, then converts the relational tensor in thetarget neural network into a product of a target number of relationshipmatrices, and generates a candidate neural network including the targetnumber of converted relationship matrices, and finally generates aresulting neural network using the candidate neural network, therebyreducing the number of parameters of the neural network by convertingthe relational tensor in the neural network into the product of thetarget number of relationship matrices, further reducing the complexityof the neural network, and facilitating reducing the CPU consumption andimproving the information processing efficiency when performinginformation processing using the neural network.

Further referring to FIG. 6 , as an implementation of the method shownin the above FIG. 4 , an embodiment of the present disclosure providesan apparatus for updating a knowledge graph. An embodiment of theapparatus may correspond to the embodiment of the method shown in FIG. 4. The apparatus may be specifically applied to various electronicdevices.

As shown in FIG. 6 , the apparatus 600 for updating a knowledge graphaccording to the present embodiment includes: a second acquiring unit601, a result generating unit 602, and a graph updating unit 603. Thesecond acquiring unit 601 is configured to acquire two to-be-associatedentity vectors and a pre-generated resulting neural network, theto-be-associated entity vector being used for characterizingto-be-associated entities in a target knowledge graph, the resultingneural network being generated using the method according to thecorresponding embodiment of FIG. 2 ; the result generating unit 602 isconfigured to input the acquired two to-be-associated entity vectorsinto the resulting neural network, to generate an association result forcharacterizing whether an association relationship between the twoto-be-associated entities is a preset association relationshipcorresponding to the resulting neural network; and the graph updatingunit 603 is configured to update the target knowledge graph, in responseto determining the association result indicating the associationrelationship between the two to-be-associated entities being the presetassociation relationship corresponding to the resulting neural network,using association information preset for the preset associationrelationship and to be added to the knowledge graph.

In the present embodiment, the second acquiring unit 601 of theapparatus 600 for updating a knowledge graph can acquire twoto-be-associated entity vectors and a pre-generated resulting neuralnetwork remotely or locally through a wired or wireless connection. Theto-be-associated entity vectors are used for characterizingto-be-associated entities in the target knowledge graph.

In the present embodiment, the resulting neural network is generated inaccordance with the method according to the corresponding embodiment ofthe above FIG. 2 . Specifically, the steps according to thecorresponding embodiment of FIG. 2 may be referred to.

In the present embodiment, based on the two to-be-associated entityvectors and the resulting neural network obtained by the secondacquiring unit 601, the result generating unit 602 can input theacquired two to-be-associated entity vectors into the resulting neuralnetwork, to generate the association result for characterizing whetherthe association relationship between the two to-be-associated entitiesis the preset association relationship corresponding to the resultingneural network. The association result may include at least one of thefollowing items: a word, a numeral, or a symbol.

In the present embodiment, the graph updating unit 603 can update thetarget knowledge graph, in response to determining the associationresult indicating the association relationship between the twoto-be-associated entities being the preset association relationshipcorresponding to the resulting neural network, using the associationinformation preset for the preset association relationship and to beadded to the knowledge graph.

In some alternative implementations of the present embodiment, theapparatus 600 may further include: a graph displaying unit (not shown inthe figure) configured to display the updated target knowledge graph.

It should be understood that the units disclosed in the apparatus 600may correspond to the steps in the method described with reference toFIG. 4 . Therefore, the operations, features, and resulting benefitingeffects described above for the method also apply to the apparatus 600and the units included therein. The description will not be repeatedhere.

The apparatus 600 provided in the above embodiments of the presentdisclosure can update the target knowledge graph using the resultingneural network generated using the method according to the correspondingembodiment of FIG. 2 . The resulting neural network includes fewerparameters, compared with a tensor neural network for updating theknowledge graph in the prior art. Thus, the resulting neural network canbe used to reduce the computing complexity, thereby reducing the CPUconsumption, and improving the efficiency of updating the knowledgegraph.

Referring to FIG. 7 below, a schematic structural diagram of anelectronic device 700 (e.g., the terminal device or the server in FIG. 1) adapted to implement embodiments of the present disclosure is shown.The terminal device in the embodiment of the present disclosure mayinclude, but is not limited to, mobile terminals such as a mobile phone,a notebook computer, a digital broadcast receiver, a PDA (personaldigital assistant), a PAD (tablet PC), a PMP (portable multimediaplayer), or a vehicle terminal (e.g., a vehicle navigation terminal), orfixed terminals such as a digital TV set, and a desktop computer. Theelectronic device shown in FIG. 7 is merely an example, and should notlimit the functions and scope of use of some embodiments of the presentdisclosure.

As shown in FIG. 7 , the electronic device 700 may include a processingunit (e.g., a central processing unit, or a graphics processor) 701,which may execute various appropriate actions and processes inaccordance with a program stored in a read only memory (ROM) 702 or aprogram loaded into a random access memory (RAM) 703 from a storage unit708. The RAM 703 further stores various programs and data required byoperations of the electronic device 700. The processing unit 701, theROM 702 and the RAM 703 are connected to each other through a bus 704.An input/output (I/O) interface 705 is also connected to the bus 704.

In general, the following units may be connected to the I/O interface705: an input unit 606 including a touch screen, a touch pad, akeyboard, a mouse, a camera, a microphone, an accelerometer, agyroscope, or the like; an output unit 707 including a liquid crystaldisplay device (LCD), a speaker, a vibrator, or the like; a storage unit708 including a magnetic tape, a hard disk, or the like; and acommunication unit 709. The communication unit 709 may allow theelectronic device 700 to exchange data with other devices throughwireless or wired communication. While FIG. 7 shows the electronicdevice 700 having various units, it should be understood that it is notnecessary to implement or provide all of the units shown in the figure.More or fewer units may be alternatively implemented or provided.

In particular, according to some embodiments of the present disclosure,the process described above with reference to the flow chart may beimplemented in a computer software program. For example, an embodimentof the present disclosure includes a computer program product, whichincludes a computer program that is tangibly embedded in a computerreadable medium. The computer program includes program codes forexecuting the method illustrated in the flow chart. In such anembodiment, the computer program may be downloaded and installed from anetwork via the communication unit 709, or be installed from the storageunit 708, or be installed from the ROM 702. The computer program, whenexecuted by the processing unit 701, executes the functions as definedby the method of some embodiments of the present disclosure.

It should be noted that the computer readable medium according to thepresent disclosure may be a computer readable signal medium or acomputer readable storage medium, or any combination of the above two.An example of the computer readable storage medium may include, but isnot limited to: electric, magnetic, optical, electromagnetic, infrared,or semiconductor systems, apparatuses, elements, or a combination of anyof the above. A more specific example of the computer readable storagemedium may include, but is not limited to: electrical connection withone or more pieces of wire, a portable computer disk, a hard disk, arandom access memory (RAM), a read only memory (ROM), an erasableprogrammable read only memory (EPROM or flash memory), an optical fiber,a portable compact disk read only memory (CD-ROM), an optical memory, amagnetic memory, or any suitable combination of the above. In thepresent disclosure, the computer readable storage medium may be anytangible medium containing or storing programs which may be used by, orused in combination with, a command execution system, apparatus orelement. In the present disclosure, the computer readable signal mediummay include data signal in the base band or propagating as parts of acarrier wave, in which computer readable program codes are carried. Thepropagating data signal may take various forms, including but notlimited to an electromagnetic signal, an optical signal, or any suitablecombination of the above. The computer readable signal medium mayfurther be any computer readable medium except for the computer readablestorage medium. The computer readable signal medium is capable oftransmitting, propagating or transferring programs for use by, or usedin combination with, a command execution system, apparatus or element.The program codes contained on the computer readable medium may betransmitted with any suitable medium, including but not limited to:wire, optical cable, RF (radio frequency) medium etc., or any suitablecombination of the above.

The computer readable medium may be included in the above electronicdevice; or a stand-alone computer readable medium without beingassembled into the electronic device. The computer readable mediumstores one or more programs. The one or more programs, when executed bythe electronic device, cause the electronic device to: acquire a targetneural network, the target neural network corresponding to a presetassociation relationship, and being configured to use two entity vectorscorresponding to two entities in a target knowledge graph as an input,to determine whether an association relationship between the twoentities corresponding to the inputted two entity vectors is the presetassociation relationship, the target neural network including arelational tensor predetermined for the preset association relationship;convert the relational tensor in the target neural network into aproduct of a target number of relationship matrices, and generate acandidate neural network including the target number of convertedrelationship matrices; and generate a resulting neural network using thecandidate neural network.

In addition, the one or more programs, when executed by the electronicdevice, can further cause the electronic device to: acquire twoto-be-associated entity vectors and a pre-generated resulting neuralnetwork, the to-be-associated entity vector being used forcharacterizing to-be-associated entities in a target knowledge graph,the resulting neural network being generated using the method of any oneembodiment of the corresponding embodiments of FIG. 2 ; input theacquired two to-be-associated entity vectors into the resulting neuralnetwork, to generate an association result for characterizing whether anassociation relationship between the two to-be-associated entities is apreset association relationship corresponding to the resulting neuralnetwork; and update the target knowledge graph, in response todetermining the association result indicating the associationrelationship between the two to-be-associated entities being the presetassociation relationship corresponding to the resulting neural network,using association information preset for the preset associationrelationship and to be added to the knowledge graph.

A computer program code for executing operations in the presentdisclosure may be compiled using one or more programming languages orcombinations thereof. The programming languages include object-orientedprogramming languages, such as Java, Smalltalk or C++, and also includeconventional procedural programming languages, such as “C” language, orsimilar programming languages. The program code may be completelyexecuted on a user's computer, partially executed on a user's computer,executed as a separate software package, partially executed on a user'scomputer and partially executed on a remote computer, or completelyexecuted on a remote computer or server. In a circumstance involving aremote computer, the remote computer may be connected to a user'scomputer through any network, including local area network (LAN) or widearea network (WAN), or be connected to an external computer (forexample, connected through the Internet using an Internet serviceprovider).

The flow charts and block diagrams in the accompanying drawingsillustrate architectures, functions and operations that may beimplemented according to the systems, methods and computer programproducts of the various embodiments of the present disclosure. In thisregard, each of the blocks in the flow charts or block diagrams mayrepresent a module, a program segment, or a code portion, said module,program segment, or code portion including one or more executableinstructions for implementing specified logical functions. It should befurther noted that, in some alternative implementations, the functionsdenoted by the blocks may also occur in a sequence different from thesequences shown in the figures. For example, any two blocks presented insuccession may be executed substantially in parallel, or they maysometimes be executed in a reverse sequence, depending on the functionsinvolved. It should be further noted that each block in the blockdiagrams and/or flow charts as well as a combination of blocks in theblock diagrams and/or flow charts may be implemented using a dedicatedhardware-based system executing specified functions or operations, or bya combination of dedicated hardware and computer instructions.

The units involved in some embodiments of the present disclosure may beimplemented by software or hardware. The names of the units do notconstitute a limitation to such units themselves in some cases. Forexample, the first acquiring unit may be further described as “a unitconfigured to acquire a target neural network.”

The above description only provides an explanation of the preferredembodiments of the present disclosure and the employed technicalprinciples. It should be appreciated by those skilled in the art thatthe inventive scope of the present disclosure is not limited to thetechnical solutions formed by the particular combinations of theabove-described technical features. The inventive scope should alsocover other technical solutions formed by any combinations of theabove-described technical features or equivalent features thereofwithout departing from the concept of the disclosure, for example,technical solutions formed by the above-described features beinginterchanged with, but not limited to, technical features with similarfunctions disclosed in the present disclosure.

What is claimed is:
 1. A method for generating a neural network,comprising: acquiring a target neural network, the target neural networkcorresponding to a preset association relationship and being configuredto use two inputted entity vectors corresponding to two entities in atarget knowledge graph as an input; determining whether an associationrelationship between the two entities corresponding to the two inputtedentity vectors is the preset association relationship, the target neuralnetwork comprising a relational tensor predetermined for the presetassociation relationship; converting the relational tensor in the targetneural network into a product of a target number of relationshipmatrices; generating a candidate neural network comprising the targetnumber of relationship matrices; and generating a resulting neuralnetwork using the candidate neural network, wherein converting therelational tensor in the target neural network into the product of thetarget number of relationship matrices comprises: by using a presetconversion method, converting the relational tensor in the target neuralnetwork into the product of the target number, determined based on thepreset conversion method, of relationship matrices, such that a summednumber of elements in the target number of relationship matrices is lessthan a number of elements in the relational tensor.
 2. The methodaccording to claim 1, wherein the generating of the resulting neuralnetwork using the candidate neural network comprises: acquiring atraining sample set for the preset association relationship, wherein:the training sample set comprises a positive training sample and anegative training sample, a training sample comprises two sample entityvectors, a sample entity vector is used for characterizing a sampleentity, the association relationship between the two entitiescorresponding to the positive training sample is the preset associationrelationship, and the association relationship between the two entitiescorresponding to the negative training sample is not the presetassociation relationship; and selecting a training sample from thetraining sample set; and executing following training: training thecandidate neural network using the selected training sample; determiningwhether the training the candidate neural network is completed; anddetermining, in response to determining the training the candidateneural network being completed, the trained candidate neural network asthe resulting neural network.
 3. The method according to claim 2,wherein the generating the resulting neural network using the candidateneural network further comprises: reselecting, in response todetermining the training the candidate neural network being uncompleted,another training sample from unselected training samples comprised inthe training sample set, adjusting a parameter of the candidate neuralnetwork, and continuing to execute the training using a most recentlyselected training sample and a most recently adjusted candidate neuralnetwork.
 4. The method according to claim 2, wherein the acquiring ofthe training sample set for the preset association relationshipcomprises: acquiring the positive training sample set for the presetassociation relationship; determining, for the positive training samplein the positive training sample set, a to-be-retained sample entityvector and a to-be-replaced sample entity vector from the positivetraining sample; acquiring a new sample entity vector from the positivetraining sample set for replacement for the to-be-replaced sample entityvector, wherein the sample entity corresponding to the new sample entityvector for replacement is different from the sample entity correspondingto the to-be-replaced sample entity vector; and using the new sampleentity vector for replacement and the to-be-retained sample entityvector to form the negative training sample corresponding to thepositive training sample; and using the positive training sample set andthe formed negative training sample to form the training sample set. 5.The method according to claim 1, wherein the method further comprises:storing the resulting neural network.
 6. A method for updating aknowledge graph, comprising: acquiring two to-be-associated entityvectors and a pre-generated resulting neural network, the twoto-be-associated entity vectors being used for characterizing twoto-be-associated entities in the target knowledge graph, thepre-generated resulting neural network being generated using the methodaccording to claim 1; inputting the two to-be-associated entity vectorsinto the pre-generated resulting neural network, to generate anassociation result for characterizing whether an associationrelationship between the two to-be-associated entities is the presetassociation relationship corresponding to the pre-generated resultingneural network; and updating the target knowledge graph, in response todetermining the association result indicating the associationrelationship between the two to-be-associated entities being the presetassociation relationship corresponding to the pre-generated resultingneural network, using association information preset for the presetassociation relationship and to be added to the knowledge graph.
 7. Themethod according to claim 6, wherein the method further comprises:displaying the updated target knowledge graph.
 8. An apparatus forgenerating a neural network, comprising: at least one processor; and amemory storing instructions, the instructions stored in memory, whenexecuted by the at least one processor, cause the at least one processorto perform operations, the operations comprising: acquiring a targetneural network, the target neural network corresponding to a presetassociation relationship and being configured to use two inputted entityvectors corresponding to two entities in a target knowledge graph as aninput; determining whether an association relationship between the twoentities corresponding to the inputted two entity vectors is the presetassociation relationship, the target neural network comprising arelational tensor predetermined for the preset association relationship;converting the relational tensor in the target neural network into aproduct of a target number of relationship matrices; generating acandidate neural network comprising the target number of relationshipmatrices; and generating a resulting neural network using the candidateneural network, wherein converting the relational tensor in the targetneural network into the product of the target number of relationshipmatrices comprises: by using a preset conversion method, converting therelational tensor in the target neural network into the product of thetarget number, determined based on the preset conversion method, ofrelationship matrices, such that a summed number of elements in thetarget number of relationship matrices is less than a number of elementsin the relational tensor.
 9. The apparatus according to claim 8, whereinthe generating the resulting neural network using the candidate neuralnetwork comprises: acquiring a training sample set for the presetassociation relationship, wherein: the training sample set comprises apositive training sample and a negative training sample, a trainingsample comprises two sample entity vectors, a sample entity vector isused for characterizing a sample entity, and the associationrelationship between the two entities corresponding to the positivetraining sample is the preset association relationship, and theassociation relationship between the two entities corresponding to thenegative training sample is not the preset association relationship; andselecting a training sample from the training sample set, and executingfollowing training: training the candidate neural network using theselected training sample; determining whether the training the candidateneural network is completed; and determining, in response to determiningthe training the candidate neural network being completed, the trainedcandidate neural network as the resulting neural network.
 10. Theapparatus according to claim 9, wherein the generating the resultingneural network using the candidate neural network further comprises:reselecting, in response to determining the training the candidateneural network being uncompleted, another training sample fromunselected training samples comprised in the training sample set,adjusting a parameter of the candidate neural network, and continuing toexecute the training using a most recently selected training sample anda most recently adjusted candidate neural network.
 11. The apparatusaccording to claim 9, wherein the acquiring of the training sample setfor the preset association relationship comprises: acquiring thepositive training sample set for the preset association relationship;determining, for the positive training sample in the positive trainingsample set, a to-be-retained sample entity vector and a to-be-replacedsample entity vector from the positive training sample; acquiring a newsample entity vector for replacement for the to-be-replaced sampleentity vector, wherein a sample entity corresponding to the new sampleentity vector for replacement is different from the sample entitycorresponding to the to-be-replaced sample entity vector; and using thenew sample entity vector for replacement and the to-be-retained sampleentity vector to form the negative training sample corresponding to thepositive training sample; and using the positive training sample set andthe formed negative training sample to form the training sample set. 12.The apparatus according to claim 8, wherein the operations furthercomprise: storing the resulting neural network.
 13. An apparatus forupdating a knowledge graph, comprising: at least one processor; and amemory storing instructions, the instructions when executed by the atleast one processor, cause the at least one processor to performoperations, the operations comprising: acquiring two to-be-associatedentity vectors and a pre-generated resulting neural network, the twoto-be-associated entity vectors being used for characterizing twoto-be-associated entities in the target knowledge graph, the resultingneural network being generated using the method according to claim 1;inputting the two to-be-associated entity vectors into the resultingneural network, to generate an association result for characterizingwhether an association relationship between the two to-be-associatedentities is a preset association relationship corresponding to theresulting neural network; and updating the target knowledge graph, inresponse to determining the association result indicating theassociation relationship between the two to-be-associated entities beingthe preset association relationship corresponding to the resultingneural network, using association information preset for the presetassociation relationship and to be added to the knowledge graph.
 14. Theapparatus according to claim 13, wherein the operations furthercomprise: displaying the updated target knowledge graph.
 15. Anon-transitory computer readable medium, storing a computer programthereon, wherein the computer program, when executed by a processor,causes the processor to perform the method according to claim 1.